import { get, post } from '../utils/request'
import { getToken } from '../utils/tools' // 导入获取token的方法

const headers = {
  'Content-Type': 'application/json'
}

export const loginAPI = (data) => {
  return post('/passport/admin/login', data, { headers })
}

// 获取管理员信息
export const adminInfoAPI = () => {
  // 从本地存储获取token
  const token = getToken()

  // 设置Authorization头
  const authHeaders = {
    ...headers,
    'Authorization': `Bearer ${token}` // 添加Bearer前缀
  }

  return get('/admin/basic/role/detail', null, { headers: authHeaders })
}